#include<unordered_map>
#include<queue>
using namespace std;
class TimeMap {
private:
    struct Unit {
        string value;
        int timestamp;
        Unit(string value, int timestamp) :value(value), timestamp(timestamp){

        }
        Unit() {

        }
    };

    unordered_map<string, vector<Unit>>map;
public:
    /** Initialize your data structure here. */
    TimeMap() {

    }

    void set(string key, string value, int timestamp) {
        map[key].emplace_back(value, timestamp);
    }

    string get(string key, int timestamp) {
        if (map.find(key) != map.end()) {
            auto& vec = map.find(key)->second;
            for (int i = vec.size() - 1; i >= 0; --i) {

                if (vec[i].timestamp <= timestamp)
                    return vec[i].value;
            }
        }
        return "";
    }
};

/**
 * Your TimeMap object will be instantiated and called as such:
 * TimeMap* obj = new TimeMap();
 * obj->set(key,value,timestamp);
 * string param_2 = obj->get(key,timestamp);
 */